//
// Grid Mixins
//




@mixin e-grid-generate($mode) {
	$mode-class: '';
	$mode-dir: '';

	// Grid mode
	@if ($mode == general) {
		$mode-class: ":not(.e-grid--desktop):not(.e-grid--desktop-and-tablet):not(.e-grid--tablet):not(.e-grid--tablet-and-mobile):not(.e-grid--mobile)";
	} @else {
		$mode-class: ".e-grid--" + $mode;
		$mode-dir: "-" + $mode;
	}

	// Horizontal grid
	.e-grid.e-grid--hor#{$mode-dir}#{$mode-class} {
		display: flex;
		flex-direction: column;

		&.e-grid--root {
			flex: 1;
			-ms-flex: 1 0 0; // IE10-11 fix
		}
		
		> .e-grid-item {
			flex: none;

			&.e-grid-item--fluid,
			&.e-grid-item--fluid#{$mode-dir} {
				flex: 1 0 auto;
				//-ms-flex: 1 0 0;  // IE10-11 fix
			}	
		}

		// flex ordering
		@for $i from 1 through 12 {
			> .e-grid-item.e-grid-item--order-#{$i}#{$mode-dir} {
				order: $i;
			}
		}
	}

	// Vertical grid
	.e-grid.e-grid--ver#{$mode-dir}#{$mode-class} {
		display: flex;
		flex-direction: row;

		&.e-grid--root {
			flex: 1;
			-ms-flex: 1 0 0;  // IE10-11 fix
		}
		 
		> .e-grid-item {
			flex: 0 0 auto;

			&.e-grid-item--fluid,
			&.e-grid-item--fluid#{$mode-dir} {
				flex: 1 auto; 
				-ms-flex: 1 0 0;  // IE10-11 fix
				min-width: 0;

				@include e-hack-ie {
					min-width: none;  // IE10-11 fix
				}				
			}			 
		}

		// flex ordering
		@for $i from 1 through 12 {
			> .e-grid-item.e-grid-item--order-#{$i}#{$mode-dir} {
				order: $i;
			}
		}
	}	 

	// Grid item order
	.e-grid {
		// horizontal items aligment
		&.e-grid--center {
			align-content: center;
		}	

		&.e-grid--stretch {
			align-items: stretch;
		}	

		// vertical item alignment
		> .e-grid-item {
			max-width:100%;
			
			&.e-grid-item--top {
				align-self: flex-start;
			}

			&.e-grid-item--middle {
				align-self: center;
			}
		 

			&.e-grid-item--bottom {
				align-self: flex-end;
			}
		}

		// flex ordering
		@for $i from 1 through 12 {
			> .e-grid-item.e-grid-item--order-#{$i} {
				order: $i;
			}
		}
	}
}